import { PageConfig } from 'next';
import anylogger from 'anylogger';
import '@mmstudio/an000042';
import an48 from '@mmstudio/an000048';
import { tbfdsys } from '../../../../atoms/db';

const logger = anylogger('pages/api/introduction/maintain/query');

export type Result = {
	pict: string;
}

export type Query = void;

/**
 * 下载展示文件
 */
const handler = an48<Result>();
const key = 'pict';

handler.get(async (req, res) => {
	try {
		logger.debug('msg body :', req.body);
		const r = await tbfdsys().first('value').where({ key });

		const pict = r?.value;
		res.status(200).json({
			pict
		});
	} catch (error) {
		logger.trace(error);
		res.status(200).json({ pict: '' });
	}
});

export const config = {} as PageConfig;

export default handler;
